import Vue from 'vue'
import Router from 'vue-router'
import Home from '../views/Home'
import Collect from '../views/Collect'
import My from '../views/My'
import Detail from '../views/Detail'
import A from '../views/A'

Vue.use(Router)
const router = new Router
    (
        {
            mode: 'history',// 去掉路由地址的#
            // base:"/",
            scrollBehavior,
            routes: [{
                path: '/home/:type',
                component: Home,
                name: 'home'
            },
            {
                path: '*',
                redirect: '/home/all?type=__all__'
            },
            {
                path: '/collect/:kind',
                component: Collect,
                name: 'collect'
            },
            {
                path: '/my',
                component: My,
                name: 'my'
            },
            {
                path: '/newsDetail/:id',
                component: Detail,
                name: 'newsdetail'
            },
            {
                path: '/a',
                component: A,
                name: 'A'
            }]
        }
    )
const scrollBehavior = (to, from, savedPosition) => {
    if (savedPosition) {
        return savedPosition
    } else {
        return { x: 0, y: 0 }
    }
}
export default router